<%@ page import="com.coolwen.entity.Student" %>
<%@ page import="org.aspectj.weaver.ast.Var" %>
<%@page pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head>
    <meta charset="utf-8"/>
    <title>学生统计表</title>
    <style>
        h4 {

            text-align: center;
        }

        table {
            border-collapse: collapse;
            margin: 0 auto;
        }

        th, td {
            width: 28px;
            font-family: "微软雅黑";
            font-size: 16px;
            vertical-align: top;
            text-align: center;
        }

        th {
            line-height: 25px;
        }

    </style>
    <script>
        function getData() {
//            document.getElementById("name").value=this.children[0].innerHTML;
            document.getElementById("course").value = this.children[1].innerHTML;
            document.getElementById('course_form').submit();
        }
    </script>
    <script src="<%=request.getContextPath()%>/resources/js/jQuery/jquery-2.1.4.min.js" type="text/javascript"></script>
    <script src="<%=request.getContextPath()%>/resources/js/info/pdata.js" type="text/javascript"></script>
</head>
<body>
<h4>四川旅游学院本科（${param.grade}级${param.major}专业）专业课程质量（学生）评价统计表</h4>
<table border="1">

    <tr>
        <td colspan="16">
            <form method="get" action="<%=request.getContextPath()%>/student/student_info">

                <select name="grade" id="input_province">
                    <option name="grade" selected><c:if test="${param.grade eq null}">请选择年级</c:if>
                        ${param.grade}</option>
                </select>

                <select name="department" id="input_city">
                    <OPTION name="department" selected><c:if test="${param.department eq null}">请选择院系</c:if>
                        ${param.department}</OPTION>
                </select>

                <select name="major" id="input_area">
                    <OPTION name="major" selected><c:if test="${param.major eq null}">请选择专业</c:if>
                        ${param.major}</OPTION>
                </select>
                <input type="submit" value="查询"/>
            </form>
        </td>

        <td colspan="3">
            <form action="<%=request.getContextPath()%>/student/out_info">
                <input type="hidden" name="grade" value="${param.grade}">
                <input type="hidden" name="department" value="${param.department}">
                <input type="hidden" name="major" value="${param.major}">
                <%--<input type="button" id="path" onclick="BrowseFolder('path')" value="选择路径"/>--%>
                <input type="submit" value="点击导出"/>
            </form>
        </td>

    </tr>
    <tr>
        <th rowspan="2" style="text-align: center;line-height: 20px;vertical-align: middle">序号</th>
        <th rowspan="2" style="text-align: center;vertical-align: middle">课程名称</th>
        <th colspan="4">第一学年<br/>（上/下）</th>
        <th colspan="4">第二学年<br/>（上/下）</th>
        <th colspan="4">第三学年<br/>（上/下）</th>
        <th colspan="4">第四学年<br/>（上/下）</th>
        <th rowspan="2" style="text-align: center;vertical-align: middle;width:70px;">总评得分</th>
    </tr>
    <tr>
        <th>参评人数</th>
        <th style="text-align: center;vertical-align: middle;">平均分数</th>
        <th>参评人数</th>
        <th style="text-align: center;vertical-align: middle;">平均分数</th>
        <th>参评人数</th>
        <th style="text-align: center;vertical-align: middle;">平均分数</th>
        <th>参评人数</th>
        <th style="text-align: center;vertical-align: middle;">平均分数</th>
        <th>参评人数</th>
        <th style="text-align: center;vertical-align: middle;">平均分数</th>
        <th>参评人数</th>
        <th style="text-align: center;vertical-align: middle;">平均分数</th>
        <th>参评人数</th>
        <th style="text-align: center;vertical-align: middle;">平均分数</th>
        <th>参评人数</th>
        <th style="text-align: center;vertical-align: middle;">平均分数</th>
    </tr>

    <c:if test="${pagers.totalPage le 0 }">
        <tr>
            <td colspan="19">无相关评教信息</td>
        </tr>
    </c:if>
    <c:if test="${pagers.totalPage gt 0}">
        <%
            int id = 0;
        %>

        <c:forEach items="${pagers.datas}" var="student" varStatus="">

            <%
                id = id + 1;
            %>

            <%--第一学年第一期--%>
            <c:if test="${fn:contains(student.semster, '第一学期')}">
                <c:if test="${fn:substring(student.semster, 0, 4) - student.grade == 0}">
                    <tr class="tr">
                        <td><%=id%>
                        </td>
                        <td style="color: #003366;width: 120px;" class="ttd">${student.course}</td>
                        <td>${student.numbers}</td>
                        <td style="text-align: center;vertical-align: middle;width:70px;"><fmt:formatNumber
                                type="number" value="${student.score}" pattern="0.00"
                                maxFractionDigits="2"/></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td><fmt:formatNumber type="number" value="${student.score}" pattern="0.00"
                                              maxFractionDigits="2"/></td>
                    </tr>
                </c:if>
            </c:if>

            <%--第一学年第二期--%>
            <c:if test="${fn:contains(student.semster, '第二学期')}">
                <c:if test="${fn:substring(student.semster, 0, 4) - student.grade == 0}">
                    <tr class="tr">
                        <td><%=id%>
                        </td>
                        <td style="color: #003366;width: 120px;">${student.course}</td>
                        <td></td>
                        <td></td>
                        <td>${student.numbers}</td>
                        <td style="text-align: center;vertical-align: middle;width:70px;"><fmt:formatNumber
                                type="number" value="${student.score}" pattern="0.00"
                                maxFractionDigits="2"/></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td><fmt:formatNumber type="number" value="${student.score}" pattern="0.00"
                                              maxFractionDigits="2"/></td>
                    </tr>
                </c:if>
            </c:if>
            <%--第二学年第一期--%>
            <c:if test="${fn:contains(student.semster, '第一学期')}">
                <c:if test="${fn:substring(student.semster, 0, 4) - student.grade == 1}">
                    <tr class="tr">
                        <td><%=id%>
                        </td>
                        <td style="color: #003366;width: 120px;">${student.course}</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td>${student.numbers}</td>
                        <td style="text-align: center;vertical-align: middle;width:70px;"><fmt:formatNumber
                                type="number" value="${student.score}" pattern="0.00"
                                maxFractionDigits="2"/></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td><fmt:formatNumber type="number" value="${student.score}" pattern="0.00"
                                              maxFractionDigits="2"/></td>
                    </tr>
                </c:if>
            </c:if>
            <%--第二学年第二期--%>
            <c:if test="${fn:contains(student.semster, '第二学期')}">
                <c:if test="${fn:substring(student.semster, 0, 4) - student.grade == 1}">
                    <tr class="tr">
                        <td><%=id%>
                        </td>
                        <td style="color: #003366;width: 120px;">${student.course}</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td>${student.numbers}</td>
                        <td style="text-align: center;vertical-align: middle;width:70px;"><fmt:formatNumber
                                type="number" value="${student.score}" pattern="0.00"
                                maxFractionDigits="2"/></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td><fmt:formatNumber type="number" value="${student.score}" pattern="0.00"
                                              maxFractionDigits="2"/></td>
                    </tr>
                </c:if>
            </c:if>

            <%--第三学年第一期--%>
            <c:if test="${fn:contains(student.semster, '第一学期')}">
                <c:if test="${fn:substring(student.semster, 0, 4) - student.grade == 2}">
                    <tr class="tr">
                        <td><%=id%>
                        </td>
                        <td style="color: #003366;width: 120px;">${student.course}</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td>${student.numbers}</td>
                        <td><fmt:formatNumber type="number" value="${student.score}" pattern="0.00"
                                              maxFractionDigits="2"/></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td><fmt:formatNumber type="number" value="${student.score}" pattern="0.00"
                                              maxFractionDigits="2"/></td>
                    </tr>
                </c:if>
            </c:if>

            <%--第三学年第二期--%>
            <c:if test="${fn:contains(student.semster, '第二学期')}">
                <c:if test="${fn:substring(student.semster, 0, 4) - student.grade == 2}">
                    <tr class="tr">
                        <td><%=id%>
                        </td>
                        <td style="color: #003366;width: 120px;">${student.course}</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td>${student.numbers}</td>
                        <td style="text-align: center;vertical-align: middle;width:70px;"><fmt:formatNumber
                                type="number" value="${student.score}" pattern="0.00"
                                maxFractionDigits="2"/></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td><fmt:formatNumber type="number" value="${student.score}" pattern="0.00"
                                              maxFractionDigits="2"/></td>
                    </tr>
                </c:if>
            </c:if>
            <%--第四学年第一期--%>
            <c:if test="${fn:contains(student.semster, '第一学期')}">
                <c:if test="${fn:substring(student.semster, 0, 4) - student.grade == 3}">
                    <tr class="tr">
                        <td><%=id%>
                        </td>
                        <td style="color: #003366;width: 120px;">${student.course}</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td>${student.numbers}</td>
                        <td style="text-align: center;vertical-align: middle;width:70px;"><fmt:formatNumber
                                type="number" value="${student.score}" pattern="0.00"
                                maxFractionDigits="2"/></td>
                        <td></td>
                        <td></td>
                        <td><fmt:formatNumber type="number" value="${student.score}" pattern="0.00"
                                              maxFractionDigits="2"/></td>
                    </tr>
                </c:if>
            </c:if>

            <%--第四学年第二期--%>
            <c:if test="${fn:contains(student.semster, '第二学期')}">
                <c:if test="${fn:substring(student.semster, 0, 4) - student.grade == 3}">
                    <tr class="tr">
                        <td><%=id%>
                        </td>
                        <td style="color: #003366;width: 120px;">${student.course}</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td>${student.numbers}</td>
                        <td style="text-align: center;vertical-align: middle;width:70px;"><fmt:formatNumber
                                type="number" value="${student.score}" pattern="0.00"
                                maxFractionDigits="2"/></td>
                        <td><fmt:formatNumber type="number" value="${student.score}" pattern="0.00"
                                              maxFractionDigits="2"/></td>
                    </tr>
                </c:if>
            </c:if>

        </c:forEach>
        <tr>
            <td colspan="19">
                <jsp:include page="/jsp/pager.jsp">
                    <jsp:param value="/student/student_info" name="url"/>
                    <jsp:param value="${pagers.totalPage }" name="items"/>
                    <jsp:param value="grade,department,major" name="params"/>
                </jsp:include>
            </td>
        </tr>

    </c:if>

</table>
<br/>
<form action="<%=request.getContextPath()%>/course/studentInfo" id="course_form" method="get">
    <input type="hidden" name="grade" value="${param.grade}">
    <input type="hidden" name="department" value="${param.department}">
    <input type="hidden" name="major" value="${param.major}">
    <input type="hidden" id="course" name="course"/>
</form>
<script type="text/javascript">
    var tds = document.getElementsByClassName("tr");
    var obj = null;
    for (var i = 0, len = tds.length; i < len; i++) {
        obj = tds[i];
        obj.onclick = getData;  //这里没有括号
    }
</script>
</body>
</html>
<script type="text/javascript">
    $(function () {
        var html = "<option value=''>年级列表</option>";
        $("#input_city").append(html);
        $("#input_area").append(html);
        $.each(pdata, function (idx, item) {
            if (parseInt(item.level) == 0) {
                html += "<option value='" + item.names + "' exid='" + item.code + "'>" + item.names + "</option>";
            }
        });
        $("#input_province").append(html);

        $("#input_province").change(function () {
            if ($(this).val() == "") return;
            $("#input_city option").remove();
            $("#input_area option").remove();
            var code = $(this).find("option:selected").attr("exid");
            code = code.substring(0, 2);
            var html = "<option value=''>院/系列表</option>";
            $("#input_area").append(html);
            $.each(pdata, function (idx, item) {
                if (parseInt(item.level) == 1 && code == item.code.substring(0, 2)) {
                    html += "<option value='" + item.names + "' exid='" + item.code + "'>" + item.names + "</option>";
                }
            });
            $("#input_city").append(html);
        });

        $("#input_city").change(function () {
            if ($(this).val() == "") return;
            $("#input_area option").remove();
            var code = $(this).find("option:selected").attr("exid");
            code = code.substring(0, 4);
            var html = "<option value=''>专业列表</option>";
            $.each(pdata, function (idx, item) {
                if (parseInt(item.level) == 2 && code == item.code.substring(0, 4)) {
                    html += "<option value='" + item.names + "' exid='" + item.code + "'>" + item.names + "</option>";
                }
            });
            $("#input_area").append(html);
        });
        //绑定
//        $("#input_province").val("广东省");$("#input_province").change();
//        $("#input_city").val("深圳市");$("#input_city").change();
//        $("#input_area").val("罗湖区");

    });
</script>
<script src="<%=request.getContextPath()%>/resources/js/list.js"></script>
<script src="<%=request.getContextPath()%>/resources/js/click.js"></script>